import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:yi_shop/components/barter/info.dart';
import 'package:yi_shop/ui/keep_alive.dart';
import 'package:yi_shop/utils/styles.dart';
import 'package:yi_shop/utils/tools.dart';

class SaleBarterInfoController extends GetxController {
  RxInt status = 1.obs;

  @override
  void onInit() {
    if (Get.arguments != null) {
      var map = Get.arguments;
      status.value = map['status'] as int;
    }
    Get.log('status = ${status.value}');
    super.onInit();
  }
}

class SaleBarterInfoPage extends GetView<SaleBarterInfoController> {
  const SaleBarterInfoPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        leading: ToolsUtils.builderLeading(),
        title: Text(
          '换货详情',
          style: StylesUtils.customTextStyle(
              fontSize: StylesUtils.fontSize18, fontWeight: FontWeight.w700),
        ),
      ),
      body: Obx(() {
        switch (controller.status.value) {
          case 1:
            return KeepAliveWrapperTabView(
              child: const BarterInfoApplyView(),
              callback: () {
                Get.put(BarterInfoApplyController());
              },
            );
          case 2:
            return KeepAliveWrapperTabView(
              child: const BarterInfoAgreeView(),
              callback: () {
                Get.put(BarterInfoAgreeController());
              },
            );
          case 3:
            return KeepAliveWrapperTabView(
              child: const BarterInfoDeliveryView(),
              callback: () {
                Get.put(BarterInfoDeliveryController());
              },
            );
          default:
            return KeepAliveWrapperTabView(
              child: const BarterInfoSucceedView(),
              callback: () {
                Get.put(BarterInfoSucceedController());
              },
            );
        }
      }),
    );
  }
}
